import {
    clearLocalStorage,
    getLocalStorage,
    setLocalStorage
} from './localStore'

enum Keys {
    Token = 'token',
    ExpireTime = 'expireTime'
}
//存储token到session
export const setToken = (token: string) => {
    // sessionStorage.setItem(Keys.Token, token)
    setLocalStorage(Keys.Token, token)
}
export const getToken = () => {
    // return sessionStorage.getItem(Keys.Token)
    return getLocalStorage(Keys.Token)
}
//存储过期时间
export const setExpireTime = (time: number) => {
    sessionStorage.setItem(Keys.ExpireTime, JSON.stringify(time))
}
export const getExpireTime = () => {
    return sessionStorage.getItem(Keys.ExpireTime)
}
export const cleanSession = () => {
    sessionStorage.clear()
    clearLocalStorage()
}
